#!/usr/bin/env python
#encoding=utf-8
__author__ = 'Zhaokun'

""" wxPython实战 part 1 wxPython入门 """

import wx

#==============================================================
class MyFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, -1, 'My Frame', size=(300, 300))
        panel = wx.Panel(self, -1)
        panel.Bind(wx.EVT_MOTION, self.OnMove)
        wx.StaticText(panel, -1, 'Pos:', pos=(10, 12))
        self.posCtrl = wx.TextCtrl(panel, -1, '', pos=(40, 10))

    def OnMove(self, event):
        pos = event.GetPosition()
        self.posCtrl.SetValue("%s, %s" % (pos.x, pos.y))
#==============================================================
class Frame(wx.Frame):
    '''Frame class that displays an image'''

    def __init__(self, image, parent=None, id=-1,
                 pos=wx.DefaultPosition,
                 title='Hello, wxPython!'):
        temp = image.ConvertToBitmap()
        print temp
        size = temp.GetWidth(), temp.GetHeight()
        print size
        wx.Frame.__init__(self, parent, id, title, pos, size)
        self.bmp = wx.StaticBitmap(parent=self, bitmap=temp)
        
class App(wx.App):
    def OnInit(self):
        image = wx.Image('shafa.bmp', wx.BITMAP_TYPE_BMP)
        print image
        self.frame = Frame(image)
#        self.frame = Frame(parent=None, title='Spare')
        self.frame.Show()
        self.SetTopWindow(self.frame)
        return True
#    def __init__(self):
#        wx.App.__init__(self)
#        frame = wx.Frame(parent=None)
#        frame.Show()
#==============================================================
class BitmapFrame(wx.Frame):
    def __init__(self, image, parent=None, id=-1,
                 pos=wx.DefaultPosition,
                 title='Hello, wxPython!'):
        temp = image.ConvertToBitmap() # 图片先转换成位图
        size = temp.GetWidth(), temp.GetHeight()
        wx.Frame.__init__(self, parent, id, title, pos, size)
        self.bmp = wx.StaticBitmap(parent=self, bitmap=temp)

class BitmapApp(wx.App):
    def OnInit(self):
        image = wx.Image(u'户型.jpg', wx.BITMAP_TYPE_JPEG) #首先加载一个图片
        self.frame = BitmapFrame(image)
        self.frame.Show()
        self.SetTopWindow(self.frame)
        return True
def BitmapMain():
    app = BitmapApp()
    app.MainLoop()

####################################################################################


if __name__ == '__main__':
    BitmapMain()



  